log using dtw_mdpa_final_70518, replace

// Replication file for final version of Dancey, Tarpey, and Woon, 
// "The Macro Dynamics of Partisan Advantage"
// Forthcoming, Political Research Quarterly
// Final version of replication file, 7/6/18
// Page numbers refer to final MS Word version
// This code was run using Stata 15

use dtw_mdpa_70518.dta, clear


***Main Analysis***

// Figure 1 - Democratic Advantage time series plot
tsset qdate
tsline demadv, xtitle(Quarter, margin(small)) ytitle(Democratic Advantage) ///
	yline(53.16, lpattern(dash)) xlabel(80(16)225, labsize(small)) scheme(s1mono)
	
// Declare data to be time series
tsset time

// Granger causality tests (p.13) 
varsoc macrop demadv
var macrop demadv, lags(1/3)
vargranger

// Create variables for fractional difference model
arfima d.demadv
predict fddemadv, fdifference
arfima d.prezapp
predict fdprez, fdifference
arfima d.congapp
predict fdcongapp, fdifference
arfima d.policymood
predict fdpolicymood, fdifference

// Table 1 - OLS w/FD series 
regress fddemadv dividegov fdpolicymood c.fdprez##i.gopprez c.fdcongapp##i.gopcong c.fdcongapp##i.dividecong c.fdprez##presbreak c.fdcong##congbreak c.fdcong##dividebreak
estat bgodfrey

// Linear combination discussed (p. 16)
lincom fdprez+1.gopprez#c.fdprez

// Analyses post-1994 election (1995 onward) as referenced in endnote 4
tab yearquarter if time==60
regress fddemadv dividegov fdpolicymood c.fdprez##i.gopprez c.fdcongapp##i.gopcong c.fdcongapp##i.dividecong c.fdprez##presbreak c.fdcong##congbreak c.fdcong##dividebreak if time>60
lincom fdcong+1.gopcong#c.fdcong

//Table 2 - party rolls
regress fddemadv dividegov fdpolicymood c.fdprez##i.gopprez c.majroll##i.gophouse c.majroll##i.dividecong c.fdprez##presbreak c.majroll##congbreak c.majroll##dividebreak
estat bgodfrey

// Table 3 - legislative accomplishments 
// Mayhew Laws (column 1)
regress fddemadv dividegov fdpolicymood c.fdprez##i.gopprez c.mayhewlaws##i.gopcong c.mayhewlaws##i.dividecong  c.fdprez##presbreak c.mayhewlaws##congbreak c.mayhewlaws##dividebreak
estat bgodfrey
// House Wins (column 2)
regress fddemadv dividegov fdpolicymood c.fdprez##i.gopprez c.housepwin##i.gophouse c.housepwin##i.dividecong c.fdprez##presbreak c.housepwin##congbreak c.housepwin##dividebreak
estat bgodfrey
// Senate Wins (column 3)
regress fddemadv dividegov fdpolicymood c.fdprez##i.gopprez c.senpwin##i.gopsen c.senpwin##i.dividecong c.fdprez##presbreak c.senpwin##congbreak c.senpwin##dividebreak
estat bgodfrey


***Appendix***

// Figure A1 - Majority Party Rolls 
tsline majroll, xtitle(Quarters) ytitle(Majority Party Rolls)

// Table A1 - ADL
regress demadv lagdemadv dividecong dividegov policymood lagpolicymood congapp lagcongapp prezapp lagprezapp gopcong gopprez gopcong_approv laggopcong_approv gopprez_approv laggopprez_approv congbreak presbreak dividebreak presbreak_approv congbreak_approv dividecong_approv dividecong_lagapprov dividebreak_app 
est sto f_adl

// Variables for the VAR analysis in Table A2//
sum prezapp 
gen newpres= prezapp - r(mean)
replace newpres=newpres*-1 if gopprez==1
sum congapp
gen newcong= congapp - r(mean)
replace newcong=newcong*-1 if gopcong==1 
replace newcong=. if dividecong==1
sum congapp
gen newhouse= congapp - r(mean)
replace newhouse=newhouse*-1 if gophouse==1

// Table A2 - VAR models
varsoc demadv newpres newhouse policymood
var demadv newpres newhouse policymood, lags(1)

// Different lag lengths as noted in appendix
var demadv newpres newhouse policymood, lags(1/2)
vargranger
var demadv newpres newhouse policymood, lags(1/3)
vargranger
var demadv newpres newhouse policymood, lags(1/4)
vargranger

// Robustness check for periods without divided Congress
varsoc demadv newpres newcong policymood
var demadv newpres newcong policymood, lags(1)

// Different lag lengths as noted in appendix
var demadv newpres newcong policymood, lags(1/2)
vargranger
var demadv newpres newcong policymood, lags(1/3)
vargranger
var demadv newpres newcong policymood, lags(1/4)
vargranger

// Analysis mentioned in endnote 6//
// Majority Rolls//
regress demadv lagdemadv dividecong dividegov policymood lagpolicymood majroll lagmajroll prezapp lagprezapp gophouse gopprez rollrategop laggoproll gopprez_approv laggopprez_approv dividecong_roll dividecong_lroll
regress demadv lagdemadv majroll lagmajroll gophouse rollrategop 
// Mayhew Laws//
regress demadv lagdemadv dividecong dividegov policymood lagpolicymood mayhewlaws lagmayhewlaws prezapp lagprezapp gopcong gopprez mayhew_gopcong lagmayhew_gopcong gopprez_approv laggopprez_approv mayhew_divcon lagmayhew_divcon
regress demadv lagdemadv mayhewlaws lagmayhewlaws gopcong mayhew_gopcong lagmayhew_gopcong 
// House Wins//
regress demadv lagdemadv dividecong dividegov policymood lagpolicymood housepwin laghousepwin prezapp lagprezapp gophouse gopprez housepwin_gop laghousepwin_gop gopprez_approv laggopprez_approv housepwin_divgov laghousepwin_divgov
regress demadv lagdemadv housepwin laghousepwin gophouse housepwin_gop laghousepwin_gop
//Senate Wins//
regress demadv lagdemadv dividecong dividegov policymood lagpolicymood senpwin lagsenpwin prezapp lagprezapp gopsenate gopprez senpwin_gop lagsenpwin_gop gopprez_approv laggopprez_approv senpwin_divcong lagsenpwin_divcong
regress demadv lagdemad senpwin lagsenpwin gopsenate  senpwin_gop lagsenpwin_gop 


log close

